package com.cookman.gameobjects.controls;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.cookman.actions.AcceptAction;
import com.cookman.actions.Action;
import com.cookman.actions.CancelAction;
import com.cookman.assets.AssetFonts;
import com.cookman.assets.AssetMap;
import com.cookman.assets.AssetsImpl;
import com.cookman.assets.AssetsLocator;
import com.cookman.gameobjects.ActionButtons.AcceptActionActor;
import com.cookman.gameobjects.ActionButtons.ActionActor;
import com.cookman.gameobjects.ActionButtons.CancelActionActor;
import com.cookman.gameobjects.ActionButtons.listeners.ExecuteActionListener;
import com.cookman.renderers.WorldRenderer;

import java.util.List;

/**
 * Created by Cookman on 26.02.2015.
 */
public class ModalPopup extends Group {

    private Sprite background = AssetsLocator.getSpriteByAtlasRegion(AssetsImpl.MAP, AssetMap.CARDBACKGROUND);

    public String label="TEST";

    public ModalPopup() {
        super();
        this.setWidth(4.5f);
        this.setHeight(3f);
        addAcceptCancel();
    }

    private float scale = 0.5f;

    protected void addAcceptCancel() {
        float xPos = this.getWidth()-scale;
        ActionActor actionActor = new CancelActionActor(new CancelAction());
        actionActor.setX(xPos);
        addActor(actionActor);
        actionActor.addListener(new ExecuteActionListener());
        actionActor.setBounds(xPos, 0, scale, scale);
        xPos -= scale + 0.2f;
        actionActor = new AcceptActionActor(new AcceptAction());
        actionActor.setX(xPos);
        addActor(actionActor);
        actionActor.addListener(new ExecuteActionListener());
        actionActor.setBounds(xPos, 0, scale, scale);
    }

    public void draw(Batch batch, float parentAlpha) {
        batch.draw(background, this.getX(), this.getY(), this.getWidth(), this.getHeight());
        super.draw(batch, parentAlpha);
    }

    public void renderShape(ShapeRenderer shapeRenderer){

    }

    public void renderGUI(SpriteBatch batch) {
       /* float x1 = WorldRenderer.cameraGUI.position.x - WorldRenderer.ratew * (WorldRenderer.camera.position.x - getX());
        float y1 = WorldRenderer.cameraGUI.position.y + WorldRenderer.rateh * (WorldRenderer.camera.position.y - getY());
        AssetFonts.font.setScale(0.2f);
        AssetFonts.font.setColor(Color.BLACK);
        AssetFonts.font.draw(batch, label, x1, y1);*/
    }

}
